<?php

namespace app\common\validate\Order;

// 引入tp的验证器
use think\Validate;

class Order extends Validate
{
    // 验证规则
    protected $rule = [
        /* 
            require => 字段必填
            regex => 正则验证
            unique => 验证字段值在指定表或模型是否为唯一 
        */
        'user_id' => ['require'],
        'order_num' => ['require','unique:order'],
        'status' => ['require'],
        'ps_date' => ['require'],
        'ps_time' => ['require'],
        'contact_phone' => ['require'],
        'contact_name' => ['require'],
        'ys_request' => ['require'],
        'airline_id' => ['require'],
        'start_point_id' => ['require'],
        'end_point_id' => ['require'],
        'item_type_id' => ['require'],
        'item_nums' => ['require'],
        'item_weight' => ['require'],
        'is_urgent' => ['require'],
        'item_unit_id' => ['require'],

    ];

    // 错误提示信息
    protected $message = [
        'phone.require' => '手机号必填',
        'order_num.require' => '订单号必填',
        'order_num.unique' => '订单号不唯一',
        'status.require' => '状态必填',
        'ps_date.require' => '预约日期必填',
        'ps_time.require' => '预约时间必填',
        'contact_phone.require' => '联系人电话必填',
        'contact_name.require' => '联系人必填',
        'ys_request.require' => '运输要求必填',
        'airline_id.require' => '航线id必填',
        'start_point_id.require' => '起点id必填',
        'end_point_id.require' => '终点id必填',
        'item_type_id.require' => '物品类型id必填',
        'item_nums.require' => '物品数量必填',
        'item_weight.require' => '物品重量必填',
        'is_urgent.require' => '是否加急必填',
        'item_unit_id.require' => '物品单位id必填'
    ];

    // 验证场景
    protected $scene = [
        // 创建订单
        'add' => ['phone', 'order_num','status','ps_date','ps_time',
        'contact_phone','contact_name','ys_request','airline_id',
        'start_point_id','end_point_id','item_type_id','item_nums',
        'item_weight','is_urgent','item_unit_id'],
    ];
}
